﻿using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YRevitJig;

namespace YArchitech.Plumbing
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class HVACRiserPipeCreate : IExternalCommand
	{
		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			if (HVACRiserPipeCreate.hWndRevit == null)
			{
				HVACRiserPipeCreate.hWndRevit = new YJKWindowHandle(Process.GetCurrentProcess().MainWindowHandle);
			}
			return new RiserPipeExecute(HVACRiserPipeCreate.hWndRevit, this.auxjig, true).Execute(commandData);
		}

		public static YJKWindowHandle hWndRevit;

		private XAuxiliaryFrameJig auxjig;
	}
}
